package cate.game.role.mall.refresh;

import cate.game.role.Role;
import cate.game.role.RoleDependent;
import cate.game.role.mall.refresh.impl.IAutoRefresh;
import cate.game.role.mall.refresh.impl.IFreeRefresh;
import cate.game.role.mall.refresh.impl.IPayRefresh;
import cate.game.role.mall.refresh.item.AutoRefreshItem;
import cate.game.role.mall.refresh.item.FreeRefreshItem;
import cate.game.role.mall.refresh.item.PayRefreshItem;
import cate.game.role.mall.refresh.item.RefreshItem;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import easy.java.dev.note.NoteClass;

@NoteClass(value = "带有三种刷新机制的商店")
public abstract class AllRefresh extends RoleDependent implements IAutoRefresh, IFreeRefresh, IPayRefresh {
    @JsonIgnore
    AutoRefreshItem auto;
    @JsonIgnore
    FreeRefreshItem free;
    @JsonIgnore
    PayRefreshItem pay;

    public AllRefresh() {

    }

    @Override
    public void initialize(Role role) {
        super.initialize(role);
        if (auto == null) {
            auto = new AutoRefreshItem();
        }
        if (free == null) {
            free = new FreeRefreshItem();
        }
        if (pay == null) {
            pay = new PayRefreshItem();
        }
    }

    @Override
    @JsonIgnore
    public RefreshItem getAutoRefreshItem() {
        return auto;
    }

    @Override
    @JsonIgnore
    public RefreshItem getFreeRefreshItem() {
        return free;
    }

    @Override
    @JsonIgnore
    public RefreshItem getPayRefreshItem() {
        return pay;
    }

    public abstract void checkRefreshTime();

    @JsonProperty("lastAutoRefreshTime")
    public long getLastAutoRefreshTime() {
        return auto.lastRefreshTime;
    }

    @JsonProperty("payTimes")
    public int getPayTimes() {
        return pay.times;
    }

    @JsonProperty("lastPayRefreshTime")
    public long getLastPayRefreshTime() {
        return pay.lastRefreshTime;
    }

    @JsonProperty("freeTimes")
    public int getFreeTimes() {
        return free.times;
    }

    @JsonProperty("lastFreeRefreshTime")
    public long getLastFreeRefreshTime() {
        return free.lastRefreshTime;
    }
}
